package net.starwifi.duobao.web;

import net.starwifi.duobao.mvc.*;
import net.starwifi.duobao.service.AdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * 广告
 * Created by Administrator on 2015/8/14.
 */
@Controller("apiAdController")
@RequestMapping("/ad")
public class AdController extends BaseController {



    @Autowired
    private AdService adService;


    /**
     * 列表
     */
    @ResponseBody
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public Object list(Long positionId) {
        final List<Filter> filterList=new ArrayList<Filter>();
        final List<Order> orderList=new ArrayList<Order>();
        orderList.add(Order.desc("order"));
        filterList.add(Filter.eq("adPosition.id", positionId));
        return Message.createMessage(Message.success("success"), new HashMap<String, Object>() {{
            put("list", adService.getMListData(filterList,orderList));
        }});
    }

}
